library("scatterplot3d")
library('plotly')
Loading required package: ggplot2
Registered S3 methods overwritten by 'ggplot2':
method from
[.quosures rlang
c.quosures rlang
print.quosures rlang
Attaching package: 'plotly'
The following object is masked from 'package:ggplot2':
last_plot
The following object is masked from 'package:stats':
filter
The following object is masked from 'package:graphics':
layout
path <- '../data/Oxygen.csv'
df <- read.csv(path, fileEncoding="UTF-8-BOM")
head(df)
| Gender | x1 | x2 | x3 | x4 |
|---|---|---|---|---|
| 1 | 0.34 | 3.71 | 2.87 | 30.87 |
| 1 | 0.39 | 5.08 | 3.38 | 43.85 |
| 1 | 0.48 | 5.13 | 4.13 | 44.51 |
| 1 | 0.31 | 3.95 | 3.60 | 46.00 |
| 1 | 0.36 | 5.51 | 3.11 | 47.02 |
| 1 | 0.33 | 4.07 | 3.95 | 48.50 |
pairs(df[,-1])
x1 and x2, x3 and x4 have strong relationship
hist(df$x1)
hist(df$x2)
hist(df$x3)
pairs(df[,-1], col=c('red', 'blue')[unclass(as.factor(df$Gender))])
male <- which(df$Gender == '1')
female <- which(df$Gender == '2')
pairs(df[male,-1])
pairs(df[female,-1])
hist(df[male, 2], col=rgb(1,0,0,0.3), border=rgb(0,0,0,0))
hist(df[female, 2], col=rgb(0,0,1,0.3), border=rgb(0,0,0,0), add=T)
hist(df[male, 3], col=rgb(1,0,0,0.3), border=rgb(0,0,0,0))
hist(df[female, 3], col=rgb(0,0,1,0.3), border=rgb(0,0,0,0), add=T)
hist(df[male, 4], col=rgb(1,0,0,0.3), border=rgb(0,0,0,0))
hist(df[female, 4], col=rgb(0,0,1,0.3), border=rgb(0,0,0,0), add=T)
scatterplot3d(df[,c(2,3,4)], pch=16, color="steelblue")
scatterplot3d(df[,c(2,3,5)], pch=16, color="steelblue")
scatterplot3d(df[,c(3,4,5)], pch=16, color="steelblue")
fig <- plot_ly(df, x=~x1, y=~x2, z=~x3, color=~Gender, colors=c('red','blue'))
fig <- fig %>% layout(scene = list(xaxis = list(title = 'x1'),
yaxis = list(title = 'x2'),
zaxis = list(title = 'x3')))
fig
No trace type specified: Based on info supplied, a 'scatter3d' trace seems appropriate. Read more about this trace type -> https://plot.ly/r/reference/#scatter3d No scatter3d mode specifed: Setting the mode to markers Read more about this attribute -> https://plot.ly/r/reference/#scatter-mode No trace type specified: Based on info supplied, a 'scatter3d' trace seems appropriate. Read more about this trace type -> https://plot.ly/r/reference/#scatter3d No scatter3d mode specifed: Setting the mode to markers Read more about this attribute -> https://plot.ly/r/reference/#scatter-mode
fig <- plot_ly(df, x=~x1, y=~x2, z=~x4, color=~Gender, colors=c('red','blue'))
fig <- fig %>% layout(scene = list(xaxis = list(title = 'x1'),
yaxis = list(title = 'x2'),
zaxis = list(title = 'x3')))
fig
No trace type specified: Based on info supplied, a 'scatter3d' trace seems appropriate. Read more about this trace type -> https://plot.ly/r/reference/#scatter3d No scatter3d mode specifed: Setting the mode to markers Read more about this attribute -> https://plot.ly/r/reference/#scatter-mode No trace type specified: Based on info supplied, a 'scatter3d' trace seems appropriate. Read more about this trace type -> https://plot.ly/r/reference/#scatter3d No scatter3d mode specifed: Setting the mode to markers Read more about this attribute -> https://plot.ly/r/reference/#scatter-mode
fig <- plot_ly(df, x=~x2, y=~x3, z=~x4, color=~Gender, colors=c('red','blue'))
fig <- fig %>% layout(scene = list(xaxis = list(title = 'x1'),
yaxis = list(title = 'x2'),
zaxis = list(title = 'x3')))
fig
No trace type specified: Based on info supplied, a 'scatter3d' trace seems appropriate. Read more about this trace type -> https://plot.ly/r/reference/#scatter3d No scatter3d mode specifed: Setting the mode to markers Read more about this attribute -> https://plot.ly/r/reference/#scatter-mode No trace type specified: Based on info supplied, a 'scatter3d' trace seems appropriate. Read more about this trace type -> https://plot.ly/r/reference/#scatter3d No scatter3d mode specifed: Setting the mode to markers Read more about this attribute -> https://plot.ly/r/reference/#scatter-mode
qqnorm(df$x1)
qqline(df$x1)
qqnorm(df$x2)
qqline(df$x2)
qqnorm(df$x3)
qqline(df$x3)
qqnorm(df$x4)
qqline(df$x4)
qqnorm(df[male, 2])
qqline(df[male, 2])
qqnorm(df[male, 3])
qqline(df[male, 3])
qqnorm(df[male, 4])
qqline(df[male, 4])
qqnorm(df[male, 5])
qqline(df[male, 5])
qqnorm(df[female, 2])
qqline(df[female, 2])
qqnorm(df[female, 3])
qqline(df[female, 3])
qqnorm(df[female, 4])
qqline(df[female, 4])
qqnorm(df[female, 5])
qqline(df[female, 5])
shapiro.test(df$x1)
shapiro.test(df$x2)
shapiro.test(df$x3)
shapiro.test(df$x4)
Shapiro-Wilk normality test data: df$x1 W = 0.96894, p-value = 0.2094
Shapiro-Wilk normality test data: df$x2 W = 0.90363, p-value = 0.0006346
Shapiro-Wilk normality test data: df$x3 W = 0.94611, p-value = 0.02368
Shapiro-Wilk normality test data: df$x4 W = 0.97328, p-value = 0.3131
shapiro.test(df[male, 2])
shapiro.test(df[male, 3])
shapiro.test(df[male, 4])
shapiro.test(df[male, 5])
Shapiro-Wilk normality test data: df[male, 2] W = 0.96123, p-value = 0.4396
Shapiro-Wilk normality test data: df[male, 3] W = 0.96721, p-value = 0.5753
Shapiro-Wilk normality test data: df[male, 4] W = 0.93163, p-value = 0.09478
Shapiro-Wilk normality test data: df[male, 5] W = 0.93961, p-value = 0.145
shapiro.test(df[female, 2])
shapiro.test(df[female, 3])
shapiro.test(df[female, 4])
shapiro.test(df[female, 5])
Shapiro-Wilk normality test data: df[female, 2] W = 0.85519, p-value = 0.002213
Shapiro-Wilk normality test data: df[female, 3] W = 0.84752, p-value = 0.001581
Shapiro-Wilk normality test data: df[female, 4] W = 0.96358, p-value = 0.4902
Shapiro-Wilk normality test data: df[female, 5] W = 0.94409, p-value = 0.1839